﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/css/bootstrap.css" />">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/css/style.css" />">
<title>CDMS-city delivery</title>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/style.css" />">
</head>
<body>
	<section class="banner position-relative" id="home">
		<jsp:include page="../Header_act.jsp" />


		<div class="container">
			<div class="banner-text">
				<div class="slider-info">
					<div class="agileinfo-logo mt-lg-5">
						<h2>
							CDMS—— <br> 同城配送系统
						</h2>
					</div>
				</div>
			</div>
		</div>
	</section>
	<div class="col-md-12 column" style="width: 100%; text-align: center">
		<div class="orderList">
			<h1>配送信息</h1>
			| <a href="<c:url value="/manager/addOrder" />">发布配送信息</a> | <br>
			<br> <a href="<c:url value="/manager/orders"/>">|全部配送单|</a> <a
				href="<c:url value="/manager/orders?state=0"/>">|待接单|</a> <a
				href="<c:url value="/manager/orders?state=1"/>">|运送中|</a> <a
				href="<c:url value="/manager/orders?state=2"/>">|已完成|</a> <br><br>
			<form action="orderSearch" method="post"
				style="width: 100%; text-align: center">
				<input type="hidden" name="state" value="${state }" />
				<c:choose>
					<c:when test="${type eq 'senderUserName'}">
						<select name="type">
							<option value="orderId">订单号</option>
							<option value="senderUserName" selected="selected">配送员</option>
							<option value="managerUserName">发布者</option>
						</select>
					</c:when>
					<c:when test="${type eq 'managerUserName'}">
						<select name="type">
							<option value="orderId">订单号</option>
							<option value="senderUserName">配送员</option>
							<option value="managerUserName" selected="selected">发布者</option>
						</select>
					</c:when>
					<c:otherwise>
						<select name="type">
							<option value="orderId">订单号</option>
							<option value="senderUserName">配送员</option>
							<option value="managerUserName">发布者</option>
						</select>
					</c:otherwise>
				</c:choose>
				<input name="search" value="${search }" placeholder="请输入查找内容" />
				<button>查找</button>
			</form>
			<%-- 			<ul class="orderList">
				<c:forEach items="${paginationSupport.items}" var="order">
					<li>
						<div class="spittleTime">
							|| 配送单信息： | 订单号：deliverOrder_
							<c:out value="${order.orderId}" />
							<br> | 接货地址：
							<c:out value="${order.receiveAddress }" />
							&nbsp;&nbsp; 发货人电话：
							<c:out value="${order.receivePhone }" />
							&nbsp;&nbsp; || 配送地址：
							<c:out value="${order.deliverAddress }" />
							&nbsp;&nbsp; 收货人电话：
							<c:out value="${order.deliverPhone }" />
							&nbsp;&nbsp; | 配送费用：￥
							<c:out value="${order.cost }" />
							<br> || 发布时间：
							<fmt:formatDate value="${order.releaseTime}"
								pattern="yyyy-MM-dd HH:mm:ss" />
							&nbsp;&nbsp; | 发布 by
							<c:out value="${order.manager.userName }" />
							<br> || 状态信息：
							<c:choose>
								<c:when test="${order.state == 0}">
							| 待接单 |
							</c:when>
								<c:when test="${order.state == 1}">
							| 配送中 | &nbsp;&nbsp;配送员：
							<c:out value="${order.sender.userName }" />
							| 接单时间：
							<fmt:formatDate value="${order.receiveTime}"
										pattern="yyyy-MM-dd HH:mm:ss" />
								</c:when>
								<c:when test="${order.state == 2}">
							| 已完成 |  &nbsp;&nbsp;配送员：
							<c:out value="${order.sender.userName }" />
							| 完成时间：
							<fmt:formatDate value="${order.finishTime}"
										pattern="yyyy-MM-dd HH:mm:ss" />
								</c:when>
							</c:choose>

						</div>
					</li>
				</c:forEach>
			</ul> --%>
			<div style="width: 100%; text-align: center">
				<table border="1" style="width: 100%; text-align: center">
					<tr>
						<th>订单号</th>
						<th>接货地址</th>
						<th>发货人电话</th>
						<th>配送地址</th>
						<th>收货人电话</th>
						<th>配送费用</th>
						<th>发布时间</th>
						<th>发布人</th>
						<th>状态信息</th>
					</tr>
					<c:forEach items="${paginationSupport.items}" var="order">
						<!-- 注意语法  -->
						<tr>
							<td>deliverOrder_<c:out value="${order.orderId}" /></td>
							<td>${order.receiveAddress}</td>
							<td>${order.receivePhone}</td>
							<td>${order.deliverAddress}</td>
							<td>${order.deliverPhone}</td>
							<td>￥&nbsp;<c:out value="${order.cost }" /></td>
							<td><fmt:formatDate value="${order.releaseTime}"
									pattern="yyyy-MM-dd HH:mm:ss" /></td>
							<td>${order.manager.userName}</td>
							<c:choose>
								<c:when test="${order.state == 0}">
									<td>待接单</td>
								</c:when>
								<c:when test="${order.state == 1}">
									<td>配送中&nbsp;|&nbsp;配送员：${order.sender.userName}&nbsp;|&nbsp;接单时间：<fmt:formatDate
											value="${order.receiveTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								</c:when>
								<c:when test="${order.state == 2}">
									<td>已完成&nbsp;|&nbsp;配送员：${order.sender.userName}&nbsp;|&nbsp;完成时间：<fmt:formatDate
											value="${order.finishTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								</c:when>
							</c:choose>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>
		每页${paginationSupport.pageSize}条配送信息，
		第${paginationSupport.currentPageNo}/${paginationSupport.totalPageCount}页,共${paginationSupport.totalCount}条配送信息
		<c:if test="${paginationSupport.previousPage}">
			<c:choose>
				<c:when test="${not empty search }">
					<a
						href="<c:url value="/manager/orderSearch?pageNo=${paginationSupport.currentPageNo-1}&type=${type }&search=${search }&state=${state }" />">上一页</a>
				</c:when>

				<c:otherwise>
					<a
						href="<c:url value="/manager/orders?pageNo=${paginationSupport.currentPageNo-1}&state=${state }" />">上一页</a>
				</c:otherwise>
			</c:choose>
		</c:if>
		<c:if test="${paginationSupport.nextPage}">
			<c:choose>
				<c:when test="${not empty search }">
					<a
						href="<c:url value="/manager/orderSearch?pageNo=${paginationSupport.currentPageNo+1}&type=${type }&search=${search }&state=${state }" />">下一页</a>
				</c:when>

				<c:otherwise>
					<a
						href="<c:url value="/manager/orders?pageNo=${paginationSupport.currentPageNo+1}&state=${state }" />">下一页</a>
				</c:otherwise>
			</c:choose>
		</c:if>
	</div>
	<br>
	<br>
	<br>
	<jsp:include page="../Footer_act.jsp" />
</body>
</html>